package cs423.loadBalancer.core;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.BatteryManager;
import android.util.Log;
import android.widget.TextView;
/***
 * Use to get the battery info
 *
 */
public class MyBroadcastReceiver extends BroadcastReceiver {
    public int scale = -1;
    public int level = -1;
    public int voltage = -1;
    public int temp = -1;
    TextView contentTxt;
	public MyBroadcastReceiver(TextView contentTxt) {
		this.contentTxt = contentTxt;
	}
	@Override
    public void onReceive(Context context, Intent intent) {
        level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
        temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
        voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
        contentTxt.setText("Remain Battery:      " + String.valueOf(level) + "%");
        Main.batteryLevel = level;
    };
        
    @Override
    public String toString() {
		return new Integer(scale).toString();
    	
    }
}
